<?php
namespace common\models\goods;

use Yii;
use yii\db\ActiveRecord;
//use yii\behaviors\TimestampBehavior;
use common\enums\StatusEnum;
use common\helpers\RegularHelper;

class GoodsImage extends ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%goods_images}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['store_id','member_id','goods_commonid','goods_image'], 'required'],
            [['member_id','store_id','goods_image_sort','goods_commonid','is_default'], 'integer'],
            [['goods_image'], 'string', 'max' => 1000],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'goods_image_id' => 'ID',
            'member_id' => '用户ID',
            'store_id' => '店铺ID',
            'goods_commonid'=>'商品公共ID',
            'goods_image' => '图片地址',
            'goods_image_sort'=>'排序',
            'is_default' => '是否默认图',
        ];
    }


    /**
     * 场景
     *
     * @return array
     */
    public function scenarios()
    {
        return [
//            'create' => [''],
//            'backendCreate' => ['username', 'password_hash'],
            'default' => array_keys($this->attributeLabels()),
        ];
    }

    /**
     * @return array
     */
//    public function behaviors()
//    {
//        return [
//            [
//                'class' => TimestampBehavior::class,
//                'attributes' => [
//                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
//                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
//                ],
//            ],
//        ];
//    }
}
